package com.kazimsoylu.jpa.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import javax.persistence.Table;

@Entity
@Table(name="EMPLOYEES")
@SecondaryTables({
	@SecondaryTable(name="EMPLOYEE_INFO", pkJoinColumns={ @PrimaryKeyJoinColumn(name="EMPLOYEE_ID",referencedColumnName="EMPLOYEENUMBER") })
})
public class EmployeeInfo 
{
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int employeeNumber;
	
	@Column(name="FIRSTNAME")
	private String firstName;
	
	@Column(name="LASTNAME")
	private String lastName;
	
	@Column(name="JOBTITLE")
	private String jobTitle;
	
	@Column(name="EMAIL",table="EMPLOYEE_INFO")
	private String email;
	
	@Column(name="ADDRESS",table="EMPLOYEE_INFO")
	private String address;
	
	@ManyToOne
	@JoinColumn(name="DEPARTMENT_ID")
	private Department department;
	
	@Override
	public String toString()
	{
		return String.format( "Number:%d,Name:%s %s, %s, Email:%s", employeeNumber,firstName,lastName,department,email );
	}

	public int getEmployeeNumber() {
		return employeeNumber;
	}

	public void setEmployeeNumber(int employeeNumber) {
		this.employeeNumber = employeeNumber;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getJobTitle() {
		return jobTitle;
	}

	public void setJobTitle(String jobTitle) {
		this.jobTitle = jobTitle;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}
	
	
}
